:root {
    --primary-color: #2c3e50;
    --secondary-color: #e74c3c;
    --accent-color: #3498db;
    --background-color: #f8f9fa;
    --text-color: #2c3e50;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

/* Header Styles */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ninja-icon {
    font-size: 2rem;
    color: var(--secondary-color);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--secondary-color);
    transition: width 0.3s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

/* 下拉菜单样式 */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.dropdown-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dropdown-content {
    visibility: hidden;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: white;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    padding: 0.8rem 0;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.3, 0, 0.3, 1);
}

.dropdown:hover .dropdown-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 0.8rem 1.5rem;
    display: block;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.dropdown-content a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: var(--secondary-color);
    opacity: 0.1;
    transition: all 0.25s ease;
    z-index: -1;
}

.dropdown-content a:hover {
    color: var(--secondary-color);
}

.dropdown-content a:hover::before {
    width: 100%;
}

/* 二级菜单样式 */
.submenu-item {
    position: relative;
    padding: 0.3rem 0;
}

.submenu-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
}

.submenu-trigger:hover {
    color: var(--secondary-color);
    background: rgba(0, 0, 0, 0.03);
}

.submenu {
    visibility: hidden;
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    padding: 0.8rem 0;
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.3, 0, 0.3, 1);
}

.submenu-item:hover .submenu {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.submenu a {
    display: block;
    padding: 0.8rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.submenu a:hover {
    background: var(--background-color);
    color: var(--secondary-color);
    padding-left: 2rem;
}

/* Hero Section */
.hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    position: relative;
}

.hero-content {
    text-align: center;
}

.glitch-text {
    font-size: 4rem;
    text-transform: uppercase;
    position: relative;
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
        -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
        0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    animation: glitch 500ms infinite;
}

@keyframes glitch {
    0% {
        text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
            0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }

    14% {
        text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
            0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }

    15% {
        text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    49% {
        text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    50% {
        text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    99% {
        text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    100% {
        text-shadow: -0.025em 0 0 rgba(255, 0, 0, 0.75),
            -0.025em -0.025em 0 rgba(0, 255, 0, 0.75),
            -0.025em -0.05em 0 rgba(0, 0, 255, 0.75);
    }
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    opacity: 0.8;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

/* Featured Categories */
.featured-categories {
    padding: 5rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.featured-categories h2 {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--primary-color);
    font-size: 2.5rem;
}

.category-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.category-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    padding: 2rem;
}

.category-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.category-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-icon i {
    font-size: 2.5rem;
    color: white;
}

.category-content {
    text-align: center;
}

.category-content h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.category-content ul {
    list-style: none;
    padding: 0;
}

.category-content li {
    margin: 0.8rem 0;
}

.category-content a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
    padding: 0.5rem;
    border-radius: 6px;
}

.category-content a:hover {
    color: var(--secondary-color);
    background: rgba(0, 0, 0, 0.05);
}

/* 代码预览区域样式优化 */
.code-preview {
    position: relative;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.code-preview pre {
    margin: 0;
    padding: 1.5rem;
    background: #1e1e1e;
    font-size: 0.9rem;
    line-height: 1.5;
}

.code-preview code {
    font-family: 'Fira Code', monospace;
}

/* Code Examples Section */
.code-examples {
    padding: 5rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.code-examples h2 {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--primary-color);
    font-size: 2rem;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin: 0 auto;
}

.example-card {
    background: #1e1e1e;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    font-size: 0.85rem;
    height: fit-content;
}

.example-header {
    background: #252526;
    color: #cccccc;
    padding: 0.5rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    min-height: 40px;
    gap: 1rem;
    /* 添加间距 */
}

.example-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-family: 'Segoe UI', system-ui, sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 100px);
    /* 确保标题不会过度挤压语言标签 */
    min-width: 0;
}

.example-header h3::before {
    content: '';
    flex: 0 0 auto;
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff605c;
    box-shadow: 12px 0 0 #ffbd44, 24px 0 0 #00ca4e;
    margin-right: 12px;
    /* 增加圆点与文字的间距 */
}

.example-header .language-tag {
    background: #333;
    color: #cccccc;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-family: 'Segoe UI', system-ui, sans-serif;
    white-space: nowrap;
    flex: 0 0 auto;
    min-width: 70px;
    /* 保证语言标签有最小宽度 */
    text-align: center;
}

.example-content {
    position: relative;
    padding: 0;
    overflow: hidden;
}

.example-content pre {
    margin: 0;
    padding: 1rem 0.5rem 1rem 3rem;
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    overflow-x: auto;
    position: relative;
}

.example-content::before {
    content: '1\A 2\A 3\A 4\A 5\A 6\A 7\A 8';
    position: absolute;
    left: 0;
    top: 1rem;
    padding: 0 0.5rem;
    color: #858585;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: right;
    background: #1e1e1e;
    border-right: 1px solid #333;
    user-select: none;
    white-space: pre;
    z-index: 1;
}

.example-description {
    padding: 0.8rem 1rem;
    background: #252526;
    border-top: 1px solid #333;
}

.example-description p {
    margin: 0;
    font-size: 0.85rem;
    color: #cccccc;
    font-family: 'Segoe UI', system-ui, sans-serif;
    line-height: 1.4;
}

/* 代码语法高亮 */
.example-content .keyword {
    color: #569cd6;
}

.example-content .string {
    color: #ce9178;
}

.example-content .comment {
    color: #6a9955;
}

.example-content .function {
    color: #dcdcaa;
}

.example-content .number {
    color: #b5cea8;
}

.example-content .operator {
    color: #d4d4d4;
}

.example-content .property {
    color: #9cdcfe;
}

/* 响应式调整优化 */
@media (max-width: 992px) {
    .examples-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .examples-grid {
        grid-template-columns: 1fr;
    }

    .example-header {
        padding: 0.5rem;
    }

    .example-content pre {
        font-size: 0.8rem;
        padding: 0.8rem 0.5rem 0.8rem 2.5rem;
    }

    .example-content::before {
        font-size: 0.8rem;
        padding: 0 0.3rem;
    }
}

/* Categories Section */
.topic-categories {
    background: var(--primary-color);
    color: white;
    padding: 5rem 2rem;
}

.category-grid {
    max-width: 1200px;
    margin: 2rem auto 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.category-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    transition: transform 0.3s ease;
}

.category-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
}

.category-card i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.category-card ul {
    list-style: none;
    margin-top: 1rem;
}

.category-card li {
    margin: 0.5rem 0;
}

/* Footer */
.footer {
    background: var(--primary-color);
    color: white;
    padding: 3rem 2rem 1rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    margin-bottom: 1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin: 0.5rem 0;
}

.footer-section a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.footer-section a:hover {
    opacity: 1;
}

.footer-bottom {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
        padding: 0.5rem;
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0.2rem;
    }

    .glitch-text {
        font-size: 2.5rem;
    }

    .dropdown {
        width: 100%;
    }

    .dropdown-trigger {
        width: 100%;
        padding: 0.8rem 1rem;
        border-radius: 8px;
    }

    .dropdown-content {
        position: static;
        visibility: visible;
        transform: none;
        opacity: 1;
        background: transparent;
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .dropdown:hover .dropdown-content {
        max-height: 1000px;
        padding: 0.8rem 0;
    }

    .submenu-item {
        padding: 0;
    }

    .submenu-trigger {
        padding: 0.8rem 1rem;
    }

    .submenu {
        position: static;
        visibility: visible;
        transform: none;
        opacity: 1;
        background: transparent;
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .submenu-item:hover .submenu {
        max-height: 1000px;
        padding: 0.4rem 0;
    }

    .submenu a {
        padding: 0.8rem 2rem;
    }

    .dropdown-content a::before {
        display: none;
    }

    .dropdown-content a:hover,
    .submenu-trigger:hover,
    .submenu a:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    .submenu-trigger i.fa-chevron-right {
        transform: rotate(90deg);
    }

    .examples-grid {
        grid-template-columns: 1fr;
    }
}

/* 文章卡片动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 下拉菜单动画 */
.dropdown-content {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.dropdown.active .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}